package com.erp.module.xiSuZhiXiang

import android.content.Context
import android.util.Log
import com.erp.contacts.Contacts
import com.erp.Interface.OnUserDataInterface
import com.erp.util.Httputil
import com.erp.util.Httputil.Call
import com.erp.util.Httputil.getparams
import org.xutils.http.HttpMethod
import org.xutils.http.RequestParams
import org.xutils.x

/**
 * Created by Administrator on 2019/3/19/019.
 * 作者：刘洋
 */
class XiSuZhiXiangModel {
    fun getJieHao(context: Context, page: Int, pagesize: Int, sousuo: IXiSuZhiXiangP.fenpeiSouSuoBean, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.GET_XISU_ZHIXIANG_SHUJU)
        params.addBodyParameter("searchParams[mc_id][0]", sousuo.wuliaoId)
        params.addBodyParameter("searchParams[onum]", sousuo.order)
        params.addBodyParameter("page", page.toString())
        params.addBodyParameter("pagesize", pagesize.toString())
        params.addBodyParameter("searchParams[mb_batch]", sousuo.sousuo)
        if ("" != sousuo.time_category) {
            params.addBodyParameter("searchParams[time_filter][time_category]", sousuo.time_category)
            params.addBodyParameter("searchParams[time_filter][start_time]", sousuo.sterttime)
            params.addBodyParameter("searchParams[time_filter][end_time]", sousuo.endtime)
        }
        getparams(context, params)
        Log.d("TAAAG", params.toString())
        x.http().get<String>(params, Call(context, onUserDataInterface))
    }

    fun setjiehao(context: Context, jo: String, jiehao: String, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.GET_XISU_ZHIXIANG_SHUJU + "/" + jiehao)
        getparams(context, params)
        Httputil.addtoken(params)
        params.addHeader("Content-Type", "application/json")
        params.bodyContent = jo
        x.http().request(HttpMethod.PUT, params, Call(context, onUserDataInterface))
    }

    /**获取物料类别代码 */
    fun getWuLiao_LeiBie_DaiMa(context: Context, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.WULIAO_DAIMA)
        getparams(context, params)
        x.http().get(params, Call(context, onUserDataInterface))
    }
}